//
//  TMTVInfoCell.m
//  TMBD Movie App
//
//  Created by zhangkai on 2023/4/11.
//

#import "TMTVInfoCell.h"
#import <Masonry.h>
#import "TMHomeSubVCCell.h"
@interface TMTVInfoCell()<UICollectionViewDelegate,UICollectionViewDataSource,UICollectionViewDelegateFlowLayout>
@property(strong,nonatomic)UIImageView *xingIcon;
@property(strong,nonatomic)UILabel *xingLabel;


@property(strong,nonatomic)UICollectionView *mainCollectionView;
@property(strong,nonatomic)NSArray *listData;
@end
@implementation TMTVInfoCell

- (void)awakeFromNib {
    [super awakeFromNib];
    // Initialization code
}

- (void)setSelected:(BOOL)selected animated:(BOOL)animated {
    [super setSelected:selected animated:animated];

    // Configure the view for the selected state
}

- (void)configDic:(NSDictionary *)dic;{
    
    NSArray *arr = [dic objectForKey:@"264"];
    

    
    
    self.listData = [arr copy];
    [self.mainCollectionView reloadData];
    
    
}

-(instancetype)initWithStyle:(UITableViewCellStyle)style reuseIdentifier:(NSString *)reuseIdentifier{
    if (self = [super initWithStyle:style reuseIdentifier:reuseIdentifier]) {
        
        self.listData = @[].copy;
        UICollectionViewFlowLayout *fl = [UICollectionViewFlowLayout new];
        fl.scrollDirection = UICollectionViewScrollDirectionHorizontal;
        self.mainCollectionView = [[UICollectionView alloc] initWithFrame:CGRectZero collectionViewLayout:fl];
        [self.contentView addSubview:self.mainCollectionView];
        self.mainCollectionView.delegate = self;
        self.mainCollectionView.dataSource = self;
        [self.mainCollectionView registerClass:[TMHomeSubVCCell class] forCellWithReuseIdentifier:@"TMHomeSubVCCell"];
        

        
        [self.mainCollectionView mas_makeConstraints:^(MASConstraintMaker *make) {
            make.edges.equalTo(self.contentView);
        }];
        self.mainCollectionView.backgroundColor = [UIColor colorWithRed:13/255.0 green:19/255.0 blue:35/255.0 alpha:1];
    }
    return self;
}

-(NSInteger)numberOfSectionsInCollectionView:(UICollectionView *)collectionView{
    return 1;
}

-(NSInteger)collectionView:(UICollectionView *)collectionView numberOfItemsInSection:(NSInteger)section{
    

    return  self.listData.count;
    
    

}

- (nonnull __kindof UICollectionViewCell *)collectionView:(nonnull UICollectionView *)collectionView cellForItemAtIndexPath:(nonnull NSIndexPath *)indexPath {
    TMHomeSubVCCell *cell = [collectionView dequeueReusableCellWithReuseIdentifier:@"TMHomeSubVCCell" forIndexPath:indexPath];
    [cell configMvieInfoUI:self.listData[indexPath.row]];
    
    cell.backgroundColor = [UIColor colorWithRed:13/255.0 green:19/255.0 blue:35/255.0 alpha:1];

    return cell;
}

-(void)collectionView:(UICollectionView *)collectionView didSelectItemAtIndexPath:(NSIndexPath *)indexPath{


}

- (CGSize)collectionView:(UICollectionView *)collectionView layout:(UICollectionViewLayout*)collectionViewLayout sizeForItemAtIndexPath:(NSIndexPath *)indexPath;{
    return CGSizeMake((kScreenW-65)/2, 250);
}
- (UIEdgeInsets)collectionView:(UICollectionView *)collectionView layout:(UICollectionViewLayout*)collectionViewLayout insetForSectionAtIndex:(NSInteger)section;{
    return  UIEdgeInsetsMake(10, 25, 10, 25);
}
- (CGFloat)collectionView:(UICollectionView *)collectionView layout:(UICollectionViewLayout*)collectionViewLayout minimumLineSpacingForSectionAtIndex:(NSInteger)section;{
    return 10;
}
- (CGFloat)collectionView:(UICollectionView *)collectionView layout:(UICollectionViewLayout*)collectionViewLayout minimumInteritemSpacingForSectionAtIndex:(NSInteger)section;{
    return 10;
}


@end
